﻿using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;

namespace Sidvall.IO
{
    public interface IStorage
    {
        int DefaultBufferSize { get; }
        string FolderDelimiter { get; }

        string Combine(params string[] paths);
        string GetFolderPath(FolderType folder);
        string GetPath(string path);
        string GetStoragePath(string path);

        Task<bool> CreateFolderAsync(string path, CancellationToken cancellationToken);

        Task<bool> DeleteFileAsync(string path, CancellationToken cancellationToken);
        Task<bool> DeleteFolderAsync(string path, bool recursive, CancellationToken cancellationToken);

        Task<bool> FileExistsAsync(string path, CancellationToken cancellationToken);
        Task<bool> FolderExistsAsync(string path, CancellationToken cancellationToken);

        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures")]
        Task<IEnumerable<string>> GetFileNamesAsync(string path, string searchPattern, SearchOption searchOption,
            CancellationToken cancellationToken);
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures")]
        Task<IEnumerable<string>> GetFolderNamesAsync(string path, string searchPattern, SearchOption searchOption,
            CancellationToken cancellationToken);
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures")]
        Task<IEnumerable<string>> GetFileSystemEntryNamesAsync(string path, string searchPattern, SearchOption searchOption,
            CancellationToken cancellationToken);

        Task<File> GetFileAsync(string fileName, bool loadFileDetails, CancellationToken cancellationToken);
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures")]
        Task<IEnumerable<File>> GetFilesAsync(string path, string searchPattern, SearchOption searchOption, bool loadFileDetails,
            CancellationToken cancellationToken);
        Task<Folder> GetFolderAsync(string folderName, bool loadFolderDetails, CancellationToken cancellationToken);
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures")]
        Task<IEnumerable<Folder>> GetFoldersAsync(string path, string searchPattern, SearchOption searchOption, bool loadFolderDetails,
            CancellationToken cancellationToken);

        Task<System.IO.Stream> OpenFileAsync(string path, FileMode mode, FileAccess access, CancellationToken cancellationToken);

        Task<bool> CopyFileAsync(string sourceFileName, string destinationFileName, bool deleteExistingFile, CancellationToken cancellationToken);
        Task<bool> MoveFileAsync(string sourceFileName, string destinationFileName, bool deleteExistingFile, CancellationToken cancellationToken);
        Task<bool> MoveFolderAsync(string sourceFolderName, string destinationFolderName, bool deleteExistingFolder, CancellationToken cancellationToken);
    }
}
